.. _example-akva-03: 03 - Saturation Indices with PHREEQC ==================================== Are these waters saturated in calcite, dolomite and gypsum? The first two akva examples answer their questions from the analysis alone. This one cannot: saturation depends on speciation, and speciation needs a chemical model. So the samples' table becomes PHREEQC's input, and the campaign is speciated one sample at a time. This is the pattern worth taking from the example. A table of measurements and a chemical model are joined by making the model's input *parameterised* and then feeding it a row at a time -- which is how a whole sampling campaign gets run through PHREEQC without writing an input file for each sample. 28 balanced samples from three of the wells of :ref:`example-akva-01` are used. Their pH and temperature are synthetic, as is the rest of the data set. An input with holes in it ------------------------- The PHREEQC input defines one solution, and everything that varies between samples is a parameter rather than a number: .. raw:: html :file: One sample.html ``@{$...$}@`` substitutes the value of an expression before PHREEQC sees the input, so what reaches PHREEQC is always an ordinary, valid input file. The two ``as`` clauses matter as much as the numbers. Sulphate is reported by the laboratory as SO4 and alkalinity as HCO3, and PHREEQC is told so rather than being left to assume: the element totals it works with are S and C, and the conversion depends on which species the figure was reported as. Getting this wrong is a quiet error -- the run succeeds and the indices are wrong. The *selected output* asks for pH, temperature and the saturation indices of calcite, dolomite and gypsum: three minerals, nine or so numbers per sample, rather than the whole speciation of each. Every parameter has a value of its own as well -- a plausible water, 15 °C, pH 7.2, Ca 100 mg/l and so on. The ``One sample`` PHREEQC study runs that single water, and it exists so the model can be checked before anything is swept over it. One simulation per row ---------------------- The ``Every sample`` study is a *Discrete Data Study*. Where a parametric study sweeps a range of values, this one takes its values from a table: it is pointed at the imported samples, and each parameter is mapped to a column of them -- .. code-block:: text T <- #T# pH <- #pH# Ca <- #Ca# ... sample <- #name# -- and it runs the study it targets once per row. 28 rows, 28 PHREEQC simulations, each with that sample's own composition. The ``sample`` parameter carries the name along so the results can be labelled. The result ---------- .. figure:: SaturationIndices.svg :alt: Saturation indices of calcite, dolomite and gypsum for 28 samples :align: center The saturation index of each mineral for every sample, with the samples as categories along the x axis. Above zero the water is supersaturated and the mineral would precipitate; below zero it is undersaturated and would dissolve. Within roughly ±0.3 the water is at equilibrium as far as the uncertainty of an analysis can tell -- which is why the band matters more than the sign of a small number. Calcite runs from 0.05 to 1.23, with 25 of the 28 samples above +0.3. Dolomite runs from 0.43 to 2.22. Gypsum is below zero everywhere, between -1.67 and -0.77. So these waters would precipitate carbonates -- in the well, in the pipework, or wherever they lose CO2 -- and would dissolve gypsum where they meet it. That is a practical conclusion about scaling, reached from a table of major-ion analyses and a ten-line input file. The carbonate indices are driven mainly by pH, which is synthetic here. With measured pH and temperature, this same project speciates a whole campaign unchanged. Source ------ * Parkhurst, D. L. and Appelo, C. A. J. (2013). *Description of input and examples for PHREEQC version 3: a computer program for speciation, batch-reaction, one-dimensional transport, and inverse geochemical calculations.* U.S. Geological Survey Techniques and Methods, book 6, chapter A43. The ``phreeqc.dat`` database and the speciation calculation are PHREEQC's. The data set is synthetic.